import { request, METHOD } from "@/service/http.service";
import { AxiosResponse } from "axios";


/**
 * 获取所有数据
 */
export function getKeypadList() {
  return request({
    url: "/keypads",
    method: METHOD.GET,
  }).then(({ data }: AxiosResponse) => {
    return data.result
  })
}

/**
 * 根据id获取数据
 */
export function getByKeypadsId(id: number) {
  return request({
    url: `/keypads/${id}`,
    method: METHOD.GET,
  })
}

/**
 * 保存
 */
export function saveKeypad(data: object) {
  return request({
    url: "/keypad",
    method: METHOD.POST,
    data
  })
}

/**
 * 修改
 */
export function updateKeypad(data: object) {
  return request({
    url: "/keypad",
    method: METHOD.PUT,
    data
  })
}

/**
 * 删除
 */
export function removekeypad(id: number) {
  return request({
    url: `/keypad/${id}`,
    method: METHOD.DELETE,
  })
}

